echo "Deploy hook called..."

# restart nginx
EXEC_CREATE=`curl --silent --unix-socket /tmp/docker.sock "http:/docker/containers/nginx/exec" -XPOST \
  -H "Content-Type: application/json" \
  -d '{
    "AttachStdout": true,
    "AttachStderr": true,
    "Tty": true,
    "Cmd": [ "nginx", "-s", "reload"]
  }'
`

echo $EXEC_CREATE | jq '.'
EXEC_ID=$(echo $EXEC_CREATE | jq -r '.Id')

curl --silent --unix-socket /tmp/docker.sock "http:/docker/exec/${EXEC_ID}/start" -XPOST \
  -H "Content-Type: application/json" \
  -d '{
    "Detach": false,
    "Tty": true
  }'
